//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package com.kitty.common.utils;

import com.kitty.game.equip.message.RespNotifyMiscEx;
import com.kitty.game.pet.model.Pet;
import com.kitty.game.role.model.Role;
import com.kitty.game.role.service.PayService;
import com.kitty.game.role.service.RoleService;
import com.kitty.mina.message.MessagePusher;
import org.nutz.dao.Dao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class GameUtil {

    @Autowired
    Dao dao;
    public GameUtil() {
    }

    public void reward(Role role, String rewardStr, String resources) {
        if (rewardStr != null) {
            String[] rewards = rewardStr.split(",");
            String[] var4 = rewards;
            int var5 = rewards.length;

            for(int var6 = 0; var6 < var5; ++var6) {
                String reward = var4[var6];
                String[] r = reward.split("\\|");
                huodechoujiang(r, role, resources);
            }
        }
    }


    public void huodechoujiang(String[] strings, Role role, String resources) {
        RoleService roleService = SpringUtils.getRoleService();
        String[] split;
        String split3;

        int currPetId = role.getTempCache("fight_current_pet_id", 0);
        if (strings[1].equals("经验")) {
            roleService.addExp(role, Integer.parseInt(strings[0]), role.getLevel() ,currPetId);
        }else if (strings[1].equals("积分")) {
            SpringUtils.getBean(PayService.class).jifen(role,Integer.parseInt(strings[0]));
        }else if (strings[1].equals("潜能")) {
            roleService.addPot(role, Integer.parseInt(strings[0]));
        }else if (strings[1].equals("道行")) {
            roleService.addTao(role, Integer.parseInt(strings[0]));
        }else if (strings[1].equals("武学")) {
            Pet pet = SpringUtils.getPetService().getPetById(role.getPetBox().getFightPetId()!=0?role.getPetBox().getFightPetId():currPetId, role);
            if (pet != null) {
                roleService.addPetMatiral(role, pet, Integer.parseInt(strings[0]));
            }
        }else if(strings[1].equals("代金卷")){
            roleService.addVoucher(role, Integer.parseInt(strings[0]));
            MessagePusher.pushMessage(role, new RespNotifyMiscEx("获得代金卷:#R"+strings[0]+"#n"));
        }else if(strings[1].equals("金钱")){
            roleService.addMoney(role, Integer.parseInt(strings[0]));
        }
    }



}
